package com.leyou.order.client;

import com.leyou.order.dto.AddressDTO;

import java.util.ArrayList;
import java.util.List;

public abstract class AddressClient {
    public static final List<AddressDTO> addressList = new ArrayList<AddressDTO>(){
        {
            AddressDTO address = new AddressDTO();
            address.setId(1L);
            address.setAddress("贺州市钟山县 3号楼");
            address.setCity("贺州");
            address.setDistrict("钟山");
            address.setName("魔晶");
            address.setPhone("18977778888");
            address.setState("广西");
            address.setZipCode("1670000");
            address.setIsDefault(true);
            add(address);

            AddressDTO address2 = new AddressDTO();
            address.setId(34L);
            address.setAddress("南宁市西乡塘区 1号楼");
            address.setCity("南宁");
            address.setDistrict("西乡塘");
            address.setName("墨镜");
            address.setPhone("18911112222");
            address.setState("广西");
            address.setZipCode("1630000");
            address.setIsDefault(false);
            add(address2);
        }
    };

    public static AddressDTO findById(Long id ){
        for (AddressDTO addressDTO : addressList) {
            if (addressDTO.getId() == id ) return addressDTO;
        }
        return null;
    }
}
